<?php
header('content-type:text/html;charset=UTF-8');

@$pageNo = $_REQUEST['pageNo'];

if (empty($pageNo)||!is_numeric($pageNo)||$pageNo<1){
	$pageNo = 1;
}

$pageSizet = 5;

$offset = ($pageNo-1)*$pageSizet;

require 'lib/db.php';

@$itemCount = dbSelect('select count(1) as x from list');

$pageCount = ceil($itemCount['x']/$pageSizet);


@$lists = dbSelectAll("select id,name,img,price from list order by id asc limit $offset,$pageSizet");

echo json_encode(array('lists'=>$lists,'pageCount'=>$pageCount));